//
//  FCUpdataAppContentVC.m
//  FundChain
//
//  Created by 肖浩然的mac on 2018/4/16.
//  Copyright © 2018年 RUIXIN. All rights reserved.
//

#import "FCUpdataAppContentVC.h"

@interface FCUpdataAppContentVC (){
    UIView     *_viewNav;
}
/* <#Annotation#> */
@property (strong, nonatomic) UILabel  *contentLabel;

@end

@implementation FCUpdataAppContentVC

- (void)viewDidLoad {
    [super viewDidLoad];
     self.view.backgroundColor = kWhiteColor;
    [FCLocalUserHelper saveIsMainVC:@"0"];
    [self setNav];
    [self loadData];
    [self setupUI];
    
}
-(void)setupUI{
    UILabel *contentLabel = [UILabel new];
    [self.view addSubview:contentLabel];
    self.contentLabel = contentLabel;
    [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(_viewNav.mas_bottom).offset(20);
        make.right.mas_equalTo(-15);
    }];
    contentLabel.numberOfLines = 0;
    
    
}
#pragma mark-设置导航栏
-(void)setNav{
    self.navigationController.navigationBarHidden = YES;
    _viewNav =[UIView new];
    [self.view addSubview:_viewNav];
    [_viewNav mas_makeConstraints:^(MASConstraintMaker *make) {
        if (@available(iOS 11.0, *)) {
            if (iPhoneX) {
                
                make.left.right.top.mas_equalTo(self.view.safeAreaInsets);
                make.height.mas_equalTo(88);
            }else{
                make.left.right.mas_equalTo(0);
                make.height.mas_equalTo(64);
                make.top.mas_equalTo(0);
            }
        }else{
            make.left.right.mas_equalTo(0);
            make.height.mas_equalTo(64);
            make.top.mas_equalTo(0);
        }
        
    }];
    _viewNav.backgroundColor = kRedOrangeColor;
    
    UIButton *leftBtn = [UIButton new];
    [self.view addSubview:leftBtn];
    [leftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15*KScreenWidthScale750);
        make.centerY.mas_equalTo(_viewNav.mas_centerY).offset(8);
        make.size.mas_equalTo(CGSizeMake(40, 40));
    }];
    [leftBtn setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
    
    [leftBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    //返回
    UILabel *backLabel = [UILabel new];
    
    [_viewNav addSubview:backLabel];
    [backLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(_viewNav);
        make.centerY.mas_equalTo(_viewNav.mas_centerY).offset(8);
    }];
    backLabel.text = Localized(@"有什么新内容");
    backLabel.textColor = [UIColor whiteColor];
    backLabel.font = KOverstrikingfont(36);
    
    //事件
    [leftBtn addTarget:self action:@selector(leftBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
}
-(void)leftBtnClick{
    
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)loadData{
    
    NSString *url = Check_version_android_URL;
    
    [FCSharedNetworkTool POSTWithURLString:url parameters:nil success:^(id responseObject) {
        
        if (responseObject) {
            
            if ([responseObject[@"code"] integerValue] == 200) {
                
                NSArray *arr = responseObject[@"result"];
                
                if (arr.count > 1) {
                    
                
                NSDictionary *dict = arr[1];
                
              Language language = [CLanguageUtil getCurrentLanguage];
                switch (language) {
                    case Language_EN:
                    {
                        self.contentLabel.text = dict[@"notiEn"];
                    }
                        break;
                    case Language_Hans:
                    {
                        self.contentLabel.text = dict[@"noti"];
                    }
                        break;
                    case Language_Hant:
                    {
                        self.contentLabel.text = dict[@"notiHK"];
                    }
                        break;
                        
                    default:
                        break;
                }
            }
            }
        }
        
    } faile:^(NSError *error) {
        
        
    }];
}

@end
